package engine

import (
	"gateway/config"
)

var runtime *engineRuntime

func Initialize(cfg *config.RoutesConfig) {
	config.Logger.Info("Initialize routes")

	runtime = newEngineRuntime()
	createConnectors(runtime, cfg)
	createInbounds(runtime, cfg)
	createOutbounds(runtime, cfg)
	createRoutes(runtime, cfg)
	initConnectors(runtime)
	initRoutes(runtime)
}

func Destroy() {
	config.Logger.Info("Destroy routes")

	destroyConnectors(runtime.connectorsRuntime)
	destroyInbounds(runtime.inboundsRuntime)
	destroyOutbounds(runtime.outboundsRuntime)
	destroyRoutes(runtime)
}
